﻿Public Class clsRandomInspection
    Public Function selRandomInspection(lotNo As String, ProcCD As String, EquipNo As String) As DataTable
        Dim szSql As String = ""

        szSql &= "SELECT LOTNO,"
        szSql &= "PROCCD,EQUIPNO,WARENO,USERNO,CHECKSPEC,"
        szSql &= "CHECKCLASSIFY,CHECKFREQ,STATUS,REMARK "
        szSql &= "FROM PER.L_RandomInspection WHERE "

        If lotNo <> "" Then
            szSql &= "LotNo = '" & lotNo & "' AND "
        End If
        If ProcCD <> "" Then
            szSql &= "ProcCD = '" & ProcCD & "' AND "
        End If
        If EquipNo <> "" Then
            szSql &= "EquipNo = '" & EquipNo & "' AND "
        End If
        szSql &= "1=1"

        Dim dt As DataTable = DBacs.ExecuteSql(szSql, -1)
        If dt Is Nothing OrElse dt.Rows.Count = 0 Then
            dt = Nothing
        End If
        Return dt
    End Function

    Public Sub updateStatus(lotNo As String, procCD As String, status As String)
        Dim szSql As String = ""

        szSql &= "UPDATE PER.L_RandomInspection SET "
        szSql &= " status = '" & status & "' "

        szSql &= "WHERE  lot_no = '" & lotNo & "' AND "
        szSql &= "procCD = '" & procCD & "' "

        DBacs.ExecuteUpdateSql(szSql, -1)
    End Sub

    Public Sub insertData(LotNo As String,
                          ProcCD As String,
                          EquipNo As String,
                          wareNo As String,
                          UserNo As String,
                          CheckSpec As String,
                          CheckClassify As String,
                          CheckFreq As String,
                          Status As String,
                          remark As String)

        Dim szSql As String = ""

        szSql = ""
        szSql &= "INSERT INTO PER.L_RandomInspection ("
        szSql &= "LotNo, ProcCD, EquipNo,wareNo,UserNo,"
        szSql &= "CheckSpec, CheckClassify, CheckFrequentness, Status, remark) "
        szSql &= "VALUES ( "
        szSql &= String.Format("'{0}', '{1}', '{2}','{3}', '{4}', '{5}','{6}', '{7}', '{8}',{9}",
                               LotNo, ProcCD, EquipNo, wareNo, UserNo, CheckSpec, CheckClassify, CheckFreq, Status, remark)
        szSql &= ")"

        DBacs.ExecuteUpdateSql(szSql, -1)

    End Sub
End Class
